﻿using System;
using System.Collections.Generic;
using System.Web;
using umbraco.cms.businesslogic.datatype;

namespace TwentyTree4Umbraco.Datatypes
{
    public class VideoPicker : AbstractDataEditor
    {
        private TwentyTree4Umbraco.Controls.VideoPicker vp = new TwentyTree4Umbraco.Controls.VideoPicker();

        public override Guid Id
        {
            get
            {
                return new Guid("F799E7E2-0405-11DF-8CC0-8CAE55D89593");
            }
        }

        public override string DataTypeName
        {
            get
            {
                return "23 VideoPicker";
            }
        }

        public VideoPicker()
        {
            base.RenderControl = vp;
            vp.Init += new EventHandler(vp_Init);
            base.DataEditorControl.OnSave += 
                new AbstractDataEditorControl.SaveEventHandler(DataEditorControl_OnSave);
        }

        void DataEditorControl_OnSave(EventArgs e)
        {
            base.Data.Value = vp.Value;
        }

        void vp_Init(object sender, EventArgs e)
        {
            vp.Value = base.Data.Value != null ? base.Data.Value.ToString() : "";
        }
    }
}
